# include <iostream>
# include <string>

// include from directory (SIS_DIR_SRC)
# include "sis.hpp" /* using _type_control */
# include "config-control.hpp" /* using _type_control */

# define NAME "get-volume-froms"
# define SOURCE NAME ".cpp"
# define TYPE _type_control

bool
less (int args__len);

bool
find (std::string str, char i);

std::string
remove (std::string str, char i);

int
to_int (std::string);

int
main (int args__len, char** args)
{
  // sis dont work without src and maybe doc
  run_virus_only_libre (SOURCE);
  
  if (less (args__len))
    return EXIT_FAILURE;

  for (int i = 0; i < args__len; i++)
    if (find(args[i], '%'))
    {
      std::cout << to_chars(remove (args[i], '%')) << std::endl;
      break;
    }

   return EXIT_SUCCESS;
}

/* if arguments too less then exit */
bool
less (int args__len)
{
  if (args__len > 1)
    return false;
  else
  {
    printf ("got 1 param please\n"
      "for example:\n"
      "\tget-volume-from `pactl get-sink-volume @DEFAULT_SINK@`\n"
      "\tget-volume-from 100%%\n");
    return true;
  }
}


bool
find (std::string str, char i)
{
  for (auto j _in str)
    if (j == i) return true;
  return false;
}


std::string
remove (std::string str, char i)
{
  // создаем переменную (result), после вернем (in sreturn);
  std::string result;
  
  // в цикле добавляем каждую букву до result if not буква i
  for (auto j _in str)
    {
      if (j != i)
        {
          result+=j;
        }
    }
  return result;
}
